var express = require('express');
var router = express.Router();
const order = require("../sql/Order")

router.get('/GetOrder', function (req, res, next) {
    const { oId } = req.query;
    
    const where = {};
    if(oId) where.oId = oId;

    order.find(where, {_id:0,__v:0}).then(data => {
        if(data.length > 0){
            res.send({
                code: 0,
                data: data,
                msg: 'success'
            });
        }else{
            res.send({
                code: 0,
                data: data,
                msg: 'not data'
            });
        }
    }).catch(code => {
        res.send({
            code: 0,
            data: null,
            msg: code
        });
    })
});

module.exports = router;
